<template>
	<view class="employment">
		<view class="head">
			<draw-popup ref="popupShow"></draw-popup>
			<view class="search">
				<input type="text" v-model="find" placeholder="找活、找工作" />
				搜索
			</view>
			<view class="classify">
				<view @click="showPopup(0)" class="type">
					{{economize ? city : addressCity}}
					<image src="../../static/下箭头.png"></image>
					<my-tree @checkAdderss="checkAdd" @Obj="Obj" ref="popupTree"></my-tree>
				</view>
				<view @click="showPopup(1)" class="type">
					{{typeTitle}}
					<image src="../../static/下箭头.png"></image>
					<my-tree ref="popupTreeType"></my-tree>
				</view>
				<view @click="showPopup(2)" class="recommend">
					{{newTitle}}
					<image src="../../static/下箭头.png"></image>
					<my-tree ref="popupTreeRecommend"></my-tree>
				</view>
			</view>
		</view>
		<view v-if="messages">
			<mescroll-body @init="mescrollInit" @down="downCallback" @up="upCallback" :down="downOption" :up="upOption">
				<view class="marge">
					<view @click="open">
						<contact-way class="module" style="margin-top: 0rpx;"></contact-way>
						<my-relation ref="popup"></my-relation>
					</view>
					<view class="advisory">
						<view class="advisory-fish">鱼泡资讯：</view>
						<swiper vertical="true" :indicator-dots="false" :autoplay="true" :interval="3000" :duration="1000">
							<swiper-item>
								<view class="swiper-item">Aasdddddddddddddddddddddddddddddddddddddddddd</view>
							</swiper-item>
							<swiper-item>
								<view class="swiper-item">B</view>
							</swiper-item>
						</swiper>
					</view>
				</view>
				<view v-for="message in messages" :key="message.id">
					<my-recruit :people="message"></my-recruit>
				</view>
			</mescroll-body>
		</view>
		<view v-else>
			<view class="noMatter">
				<image src="../../static/缺省页2_03.jpg"></image>
				<view class="lack">没有找到您想要的内容，您可以换个内容搜索</view>
				<view class="relation">还可以发布找活，让老板主动来找我</view>
				<a class="issue">去发布</a>
			</view>
		</view>
		<view @click="share" :animation="animationData" class="invitation">
			<view class="invitation-image">
				<image src="../../static/邀请.png"></image>
			</view>
			<view class="concent">邀请赚积分</view>
		</view>
		<view @click="release(13345678911)" class="issue">发布招工</view>
	</view>
</template>

<script>
	import myRecruit from '../../components/recruits.vue'
	import mescrollMixin from '../../components/mescroll-uni/mescroll-mixins.js'
	import mescrollBody from '../../components/mescroll-uni/mescroll-body.vue'
	import contactWay from '../../components/contactway.vue'
	import myRelation from '../../components/relation.vue'
	import drawPopup from '../../components/draw.vue'
	import myTree from '../../components/tree.vue'
	import Dialog from '../../wxcomponents/vant-weapp/dialog/dialog'
	export default {
		name: "employment",
		mixins: [mescrollMixin],
		data() {
			return {
				find: "",
				animationData: {},
				downOption: {},
				show: true,
				overclass: "请选择",
				addressCity: "全国",
				typeTitle: "通用",
				newTitle: "最新",
				city: "",
				economize:"",
				flag: true,
				Obj: [{
						'name': "广州",
						'secondary': ['深圳', '珠海']
					},
					{
						'name': "安徽",
						'secondary': ["安庆", "池州", "巢湖"]
					},
					{
						'name': "测试",
						'secondary': ['深圳', '珠海', "佛山", '深圳', '珠海', "佛山"]
					}
				],
				upOption: {
					page: {
						size: 10 // 每页数据的数量,默认10
					},
					noMoreSize: 5, // 配置列表的总数量要大于等于5条才显示'-- END --'的提示
					empty: {
						tip: '暂无相关数据'
					}
				},
				messages: [{
						id: 1,
						title: "测试123456789asdasdaddad",
						top: true,
						image: "../../static/首页ok_29-17.jpg",
						name: "李先生",
						concent: "招聘信息asdasdadadssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssss",
						recruiting: true,
						address: "广州",
						time: "2020-10-15 10:03"
					},
					{
						id: 2,
						title: "测试测试123456789",
						top: false,
						image: "../static/首页ok_29-17.jpg",
						name: "",
						concent: "招聘信息",
						recruiting: false,
						address: "广州天河区广州天河区广州天河区广州天河区",
						time: "2020-10-15 10:03"
					},
					{
						id: 3,
						title: "测试123456789",
						top: true,
						image: "../../static/首页ok_29-17.jpg",
						name: "李先生",
						concent: "招聘信息asdasdadadssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssss",
						recruiting: true,
						address: "广州",
						time: "2020-10-15 10:03"
					},
					{
						id: 4,
						title: "测试测试123456789",
						top: false,
						image: "../static/首页ok_29-17.jpg",
						name: "",
						concent: "招聘信息",
						recruiting: false,
						address: "广州天河区广州天河区广州天河区广州天河区",
						time: "2020-10-15 10:03"
					},
				]
			}
		},
		components: {
			'myRecruit': myRecruit,
			'mescrollBody': mescrollBody,
			'contactWay': contactWay,
			"myRelation": myRelation,
			'drawPopup': drawPopup,
			'myTree': myTree,
		},

		methods: {
			open() {
				this.$refs.popup.$refs.popups.open()
			},
			upCallback(page) {
				let self = this.messages
				let pageNum = page.num; // 页码, 默认从1开始
				let pageSize = page.size; // 页长, 默认每页10条
				let time = 2000;
				uni.request({
					url: 'xxxx?pageNum=' + pageNum + '&pageSize=' + pageSize,
					success: (data) => {
						// 接口返回的当前页数据列表 (数组)
						let curPageData = 2;
						// 接口返回的当前页数据长度 (如列表有26个数据,当前页返回8个,则curPageLen=8)
						let curPageLen = curPageData.length;
						// 接口返回的总页数 (如列表有26个数据,每页10条,共3页; 则totalPage=3)
						let totalPage = 2;
						// 接口返回的总数据量(如列表有26个数据,每页10条,共3页; 则totalSize=26)
						let totalSize = 2;
						// 接口返回的是否有下一页 (true/false)
						let hasNext = false;

						//设置列表数据
						if (page.num == 1) self.messages = []; //如果是第一页需手动置空列表
						self.messages = self.messages.concat(curPageData); //追加新数据

						// 请求成功,隐藏加载状态
						//方法一(推荐): 后台接口有返回列表的总页数 totalPage
						this.mescroll.endByPage(curPageLen, totalPage);

						setTimeout(() => {
							this.mescroll.endSuccess(curPageLen)
						}, 2000)
					},
					fail: () => {
						//  请求失败,隐藏加载状态

						this.mescroll.endErr()
					},
				})

			},
			person(id) {
				uni.navigateTo({
					url: "/pages/employment/person?id=" + id
				})
			},
			share() {
				this.$refs.popupShow.$refs.popupShow.open()
			},
			release(phone) {
				uni.navigateTo({
					url: "/pages/employment/release?phone=" + phone
				})
			},
			showPopup(flag) {
				if (this.city) {
					this.$refs.popupTree.$refs.popupTree.close();
					this.$refs.popupTree.$refs.popupTreeChild.open();
				} else{
					this.$refs.popupTree.$refs.popupTree.open();
				}

			},
			checkAdd(options, city) {
				debugger
				this.flag = options
				this.city = city
				console.info(options)
			},
			chackCity(economize){
				this.economize = economize
			}
		},

		onPageScroll() {
			let self = this
			this.animation = uni.createAnimation()
			this.animation.translateX(500).step({
				duration: 3000
			})

			this.animationData = this.animation.export()
			setTimeout(() => {
				this.animation.translateX(0).step({
					duration: 3000
				})
				this.animationData = this.animation.export()
			}, 500);

		}
	}
</script>
<style lang="scss">
	// .employment {
	// 	.module /deep/ .massage {
	// 		margin-top: 220rpx;
	// 	}
	// }
</style>
<style lang="scss" scoped>
	.employment {

		width: 100vw;
		display: flex;
		flex-direction: column;
		background: #eaeaea;

		.head {
			position: fixed;
			background: #0497ff;
			height: 11vh;
			padding: 50rpx 50rpx 0 20rpx;
			margin-bottom: 30rpx;
			z-index: 8;

			.search {
				display: flex;
				color: #FFFFFF;
				font-size: 32rpx;
				justify-content: space-between;
				align-items: center;
				margin-right: 30rpx;

				input {
					padding-right: 20rpx;
					padding-left: 10rpx;
					background-color: #FFFFFF;
					color: black;
					width: 75vw;
					border-radius: 10rpx;
					height: 60rpx;
				}
			}

			.classify {
				display: flex;
				justify-content: space-between;
				background: #FFFFFF;
				margin-top: 6rpx;
				align-items: center;
				width: 100vw;
				margin-left: -20rpx;
				padding: 0 40rpx;

				image {
					width: 30rpx;
					height: 30rpx;
					margin-left: 10rpx;
				}

				.region,
				.type,
				.recommend {
					display: flex;
					align-items: center;
					justify-content: center;
					width: 20vw;
					height: 6vh;
					white-space: nowrap;
				}
			}
		}

		.issue {
			position: fixed;
			bottom: 50rpx;
			left: 33vw;
			background: #007AFF;
			color: #FFFFFF;
			font-size: 38rpx;
			padding: 10rpx 40rpx;
			border-radius: 99rpx;
			z-index: 5;
		}

		.invitation {
			display: flex;
			flex-direction: column;
			position: fixed;
			top: 100vw;
			right: 40rpx;
			z-index: 5;
			color: #007AFF;
			font-weight: bold;

			.invitation-image {

				width: 140rpx;
				height: 140rpx;
				border-radius: 20rpx;
				background: #007AFF;
				margin-bottom: 10rpx;

				image {
					width: 140rpx;
					height: 140rpx;
				}
			}
		}

		.marge {
			display: flex;
			flex-direction: column;
			background: #FFFFFF;
			margin-bottom: 20rpx;
			margin-top: 210rpx;

			.advisory {
				height: 6vh;
				display: flex;
				margin-top: 10rpx;
				font-size: 26rpx;
				margin-left: 20rpx;

				.advisory-fish {
					color: #F0AD4E;
					line-height: 40rpx;
				}

				swiper {
					height: 4vh;
					width: 560rpx;

					.swiper-item {
						overflow: hidden;
						text-overflow: ellipsis;
					}
				}
			}
		}

		.noMatter {
			margin-top: 180rpx;
			background: #EFF0F5;
			height: 85vh;
			text-align: center;

			padding: 120rpx;

			image {
				width: 260rpx;
				height: 260rpx;
			}

			.lack {
				color: #818181;
				font-size: 30rpx;
			}

			.relation {
				font-size: 32rpx;
			}

			.issue {
				color: #007AFF;
			}
		}
	}
</style>
